﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace collection_queue_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int sum = 1200;

            Queue order = new Queue();
            
            order.Enqueue("订单"+sum++);
            order.Enqueue("订单"+sum++);
            order.Enqueue("订单"+sum++);
            Console.WriteLine("现有订单：");
            foreach(string item in order)
            {
                Console.WriteLine(item);
            }
            while(order.Count!=0)
            {
                Console.WriteLine(order.Dequeue()+"已入库");
                Thread.Sleep(500);
            }
            while (true)
            {
                Console.WriteLine("是否继续添加订单（y/n）");
                string a = Console.ReadLine();

                if (a == "y")
                {
                    order.Enqueue("订单" + sum++);
                    
                }
                else if (a == "n")
                {
                    break;

                }
            }
                Console.WriteLine("现有订单：");
                foreach (string item in order)
                {
                    Console.WriteLine(item);
                }
                Console.WriteLine("是否将订单入库（y/n）");
                var b=Console.ReadLine();
                if (b=="y")
                {
                    while (order.Count != 0)
                    {
                        Console.WriteLine(order.Dequeue() + "订单已入库");
                        Thread.Sleep(500);
                        
                    }
                Console.WriteLine("进程结束");
            }
                 else
                {
                    Console.WriteLine("进程结束");
                 }

                

            
        }
    }
}
